export default class duihuan extends Laya.Script {
    public viewFlag = 1;
    constructor() {
        super();
    }

    onEnable() {
        this.owner.getChildByName("btn1").on("click", this, () => {
            this.changeview(1)
        })
        this.owner.getChildByName("btn2").on("click", this, () => {
            this.changeview(2)
        })
        this.owner.getChildByName("btn3").on("click", this, () => {
            this.changeview(3)
        })
    }

    changeview(flag) {
        if (flag == 1) {
            //@ts-ignore
            this.owner.getChildByName("box1").visible = true;
            //@ts-ignore
            this.owner.getChildByName("box2").visible = false;
            //@ts-ignore
            this.owner.getChildByName("box3").visible = false;
            (this.owner.getChildByName("btn1") as Laya.Button).skin = "farmmain/yuanjiao1.png";
            (this.owner.getChildByName("btn2") as Laya.Button).skin = "farmmain/yuanjiao2.png";
            (this.owner.getChildByName("btn3") as Laya.Button).skin = "farmmain/yuanjiao2.png";
            (this.owner.getChildByName("txt1") as Laya.Text).color = '#b5841a';
            (this.owner.getChildByName("txt2") as Laya.Text).color = '#ffffff';
            (this.owner.getChildByName("txt3") as Laya.Text).color = '#ffffff';
        } else if (flag == 2) {
            //@ts-ignore
            this.owner.getChildByName("box1").visible = false;
            //@ts-ignore
            this.owner.getChildByName("box3").visible = false;
            //@ts-ignore
            this.owner.getChildByName("box2").visible = true;
            (this.owner.getChildByName("btn1") as Laya.Button).skin = "farmmain/yuanjiao2.png";
            (this.owner.getChildByName("btn2") as Laya.Button).skin = "farmmain/yuanjiao1.png";
            (this.owner.getChildByName("btn3") as Laya.Button).skin = "farmmain/yuanjiao2.png";
            (this.owner.getChildByName("txt1") as Laya.Text).color = '#ffffff';
            (this.owner.getChildByName("txt2") as Laya.Text).color = '#b5841a';
            (this.owner.getChildByName("txt3") as Laya.Text).color = '#ffffff';

        } else {
            //@ts-ignore
            this.owner.getChildByName("box1").visible = false;
            //@ts-ignore
            this.owner.getChildByName("box3").visible = true;
            //@ts-ignore
            this.owner.getChildByName("box2").visible = false;

            (this.owner.getChildByName("btn1") as Laya.Button).skin = "farmmain/yuanjiao2.png";
            (this.owner.getChildByName("btn2") as Laya.Button).skin = "farmmain/yuanjiao2.png";
            (this.owner.getChildByName("btn3") as Laya.Button).skin = "farmmain/yuanjiao1.png";
            (this.owner.getChildByName("txt1") as Laya.Text).color = '#ffffff';
            (this.owner.getChildByName("txt2") as Laya.Text).color = '#ffffff';
            (this.owner.getChildByName("txt3") as Laya.Text).color = '#b5841a';
        }
    }
}